<template>
  <div class="market-foot">
    <Call ref="callRef" :id="id" :data="data" @ok="handleOk" />
    <a-button @click="handleCancel" class="btn">返回</a-button>

    <!-- 已上线 -->
    <template v-if="data.status === 1">
      <a-button v-if="data.subscribeState === 0" @click="handleCall" type="primary" class="btn">申请调用</a-button>
      <a-button v-else-if="data.subscribeState === 1" disabled type="primary" class="btn">申请调用审核中</a-button>
      <a-button v-else disabled type="primary" class="btn">已申请调用通过</a-button>
    </template>
    <!-- 未上线 -->
    <template v-else>
      <a-button disabled type="primary" class="btn">面板未上线,不能申请调用</a-button>
    </template>

    <a-button v-if="data.storeState === 0" @click="handleCollection" type="primary" class="btn">申请收藏</a-button>
    <a-button v-else-if="data.storeState === 1" disabled type="primary" class="btn">申请收藏审核中</a-button>
    <a-button v-else disabled type="primary" class="btn">已申请收藏通过</a-button>
  </div>
</template>


<script>
import { mapState } from "vuex"
import Call from "./Call"
import {
  getCategoryAndDashboardListByPid,
  batchDelDashboardCategory,
  batchDelDashboard,
  kanBanOnlineOrOffline,
  applySubscribe,
  applyStore,
  upDashboard
} from "@/api/multidimensionalAnalysis"


// 状态1表示审核中
// 状态2表示审核通过
// 其它都是状态0.状态0时可以提交审核

export default {
  components: {
    Call
  },
  props: {
    id: {
      type: [Number, String],
      default: 0
    },
    data: {
      type: Object,
      default: ()=> {}
    }
  },
  data() {
    return {

      type: "preview", // market

    }
  },
  computed: {
    ...mapState("lowCode", {
      previewData: state => state.previewData
    })
  },
  created(){

  },
  methods: {
    handleCancel(){
      history.go(-1)
    },
    handleCall(){
      this.$refs.callRef.show()
    },
    handleCollection() {
      applyStore(this.id)
      .then(res => {
        if (res.code === "000000") {
          this.$message.success("申请收藏成功")
          this.handleOk()
        } else {
          this.$message.error(res.msg)
        }
      })
      .catch(err => {
        this.$message.error(err.response.data.message)
      })
    },
    handleOk(){
      this.$emit("update")
    }
  },

}
</script>

<style lang="less" scoped>
@import url("./index.less");
</style>
